home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / plaf / basic / BasicFileChooserUI.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  10.5 KB  |  336 lines

  1. package javax.swing.plaf.basic;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.event.MouseListener;
  5. import java.beans.PropertyChangeListener;
  6. import java.io.File;
  7. import javax.swing.Action;
  8. import javax.swing.Icon;
  9. import javax.swing.JButton;
  10. import javax.swing.JComponent;
  11. import javax.swing.JFileChooser;
  12. import javax.swing.JList;
  13. import javax.swing.JPanel;
  14. import javax.swing.KeyStroke;
  15. import javax.swing.UIManager;
  16. import javax.swing.event.AncestorListener;
  17. import javax.swing.event.ListSelectionListener;
  18. import javax.swing.filechooser.FileFilter;
  19. import javax.swing.filechooser.FileView;
  20. import javax.swing.plaf.FileChooserUI;
  21.  
  22. public class BasicFileChooserUI extends FileChooserUI {
  23.    protected Icon directoryIcon = null;
  24.    protected Icon fileIcon = null;
  25.    protected Icon computerIcon = null;
  26.    protected Icon hardDriveIcon = null;
  27.    protected Icon floppyDriveIcon = null;
  28.    protected Icon newFolderIcon = null;
  29.    protected Icon upFolderIcon = null;
  30.    protected Icon homeFolderIcon = null;
  31.    protected Icon listViewIcon = null;
  32.    protected Icon detailsViewIcon = null;
  33.    protected int saveButtonMnemonic = 0;
  34.    protected int openButtonMnemonic = 0;
  35.    protected int cancelButtonMnemonic = 0;
  36.    protected int updateButtonMnemonic = 0;
  37.    protected int helpButtonMnemonic = 0;
  38.    protected String saveButtonText = null;
  39.    protected String openButtonText = null;
  40.    protected String cancelButtonText = null;
  41.    protected String updateButtonText = null;
  42.    protected String helpButtonText = null;
  43.    private String newFolderErrorSeparator = null;
  44.    private String newFolderErrorText = null;
  45.    private String fileDescriptionText = null;
  46.    private String directoryDescriptionText = null;
  47.    protected String saveButtonToolTipText = null;
  48.    protected String openButtonToolTipText = null;
  49.    protected String cancelButtonToolTipText = null;
  50.    protected String updateButtonToolTipText = null;
  51.    protected String helpButtonToolTipText = null;
  52.    private Action approveSelectionAction = new ApproveSelectionAction(this);
  53.    private Action cancelSelectionAction = new CancelSelectionAction(this);
  54.    private Action updateAction = new UpdateAction(this);
  55.    private Action newFolderAction = new NewFolderAction(this);
  56.    private Action goHomeAction = new GoHomeAction(this);
  57.    private Action changeToParentDirectoryAction = new ChangeToParentDirectoryAction(this);
  58.    private JFileChooser filechooser = null;
  59.    private PropertyChangeListener propertyChangeListener = null;
  60.    private AncestorListener ancestorListener = null;
  61.    private AcceptAllFileFilter acceptAllFileFilter = new AcceptAllFileFilter(this);
  62.    private BasicDirectoryModel model = null;
  63.    private BasicFileView fileView = new BasicFileView(this);
  64.    private JPanel accessoryPanel = null;
  65.  
  66.    public BasicFileChooserUI(JFileChooser var1) {
  67.    }
  68.  
  69.    // $FF: synthetic method
  70.    static String access$0(BasicFileChooserUI var0) {
  71.       return var0.newFolderErrorText;
  72.    }
  73.  
  74.    // $FF: synthetic method
  75.    static String access$1(BasicFileChooserUI var0) {
  76.       return var0.newFolderErrorSeparator;
  77.    }
  78.  
  79.    // $FF: synthetic method
  80.    static String access$2(BasicFileChooserUI var0) {
  81.       return var0.directoryDescriptionText;
  82.    }
  83.  
  84.    // $FF: synthetic method
  85.    static String access$3(BasicFileChooserUI var0) {
  86.       return var0.fileDescriptionText;
  87.    }
  88.  
  89.    public void clearIconCache() {
  90.       this.fileView.clearIconCache();
  91.    }
  92.  
  93.    protected MouseListener createDoubleClickListener(JFileChooser var1, JList var2) {
  94.       return new DoubleClickListener(this, var2);
  95.    }
  96.  
  97.    public ListSelectionListener createListSelectionListener(JFileChooser var1) {
  98.       return new SelectionListener(this);
  99.    }
  100.  
  101.    protected void createModel() {
  102.       this.model = new BasicDirectoryModel(this.getFileChooser());
  103.    }
  104.  
  105.    public PropertyChangeListener createPropertyChangeListener(JFileChooser var1) {
  106.       return null;
  107.    }
  108.  
  109.    public void ensureFileIsVisible(JFileChooser var1, File var2) {
  110.    }
  111.  
  112.    public FileFilter getAcceptAllFileFilter(JFileChooser var1) {
  113.       return this.acceptAllFileFilter;
  114.    }
  115.  
  116.    public JPanel getAccessoryPanel() {
  117.       return this.accessoryPanel;
  118.    }
  119.  
  120.    protected JButton getApproveButton(JFileChooser var1) {
  121.       return null;
  122.    }
  123.  
  124.    public int getApproveButtonMnemonic(JFileChooser var1) {
  125.       if (this.getFileChooser().getDialogType() == 0) {
  126.          return this.openButtonMnemonic;
  127.       } else if (this.getFileChooser().getDialogType() == 1) {
  128.          return this.saveButtonMnemonic;
  129.       } else {
  130.          int var2 = this.getFileChooser().getApproveButtonMnemonic();
  131.          return var2;
  132.       }
  133.    }
  134.  
  135.    public String getApproveButtonText(JFileChooser var1) {
  136.       String var2 = this.getFileChooser().getApproveButtonText();
  137.       if (var2 != null) {
  138.          return var2;
  139.       } else if (this.getFileChooser().getDialogType() == 0) {
  140.          return this.openButtonText;
  141.       } else {
  142.          return this.getFileChooser().getDialogType() == 1 ? this.saveButtonText : null;
  143.       }
  144.    }
  145.  
  146.    public String getApproveButtonToolTipText(JFileChooser var1) {
  147.       String var2 = var1.getApproveButtonToolTipText();
  148.       if (var2 != null) {
  149.          return var2;
  150.       } else if (var1.getDialogType() == 0) {
  151.          return this.openButtonToolTipText;
  152.       } else {
  153.          return var1.getDialogType() == 1 ? this.saveButtonToolTipText : null;
  154.       }
  155.    }
  156.  
  157.    public Action getApproveSelectionAction() {
  158.       return this.approveSelectionAction;
  159.    }
  160.  
  161.    public Action getCancelSelectionAction() {
  162.       return this.cancelSelectionAction;
  163.    }
  164.  
  165.    public Action getChangeToParentDirectoryAction() {
  166.       return this.changeToParentDirectoryAction;
  167.    }
  168.  
  169.    public String getDialogTitle(JFileChooser var1) {
  170.       return this.getApproveButtonText(var1);
  171.    }
  172.  
  173.    public String getDirectoryName() {
  174.       return null;
  175.    }
  176.  
  177.    public JFileChooser getFileChooser() {
  178.       return this.filechooser;
  179.    }
  180.  
  181.    public String getFileName() {
  182.       return null;
  183.    }
  184.  
  185.    public FileView getFileView(JFileChooser var1) {
  186.       return this.fileView;
  187.    }
  188.  
  189.    public Action getGoHomeAction() {
  190.       return this.goHomeAction;
  191.    }
  192.  
  193.    public BasicDirectoryModel getModel() {
  194.       return this.model;
  195.    }
  196.  
  197.    public Action getNewFolderAction() {
  198.       return this.newFolderAction;
  199.    }
  200.  
  201.    public Action getUpdateAction() {
  202.       return this.updateAction;
  203.    }
  204.  
  205.    public void installComponents(JFileChooser var1) {
  206.    }
  207.  
  208.    protected void installDefaults(JFileChooser var1) {
  209.       this.installIcons(var1);
  210.       this.installStrings(var1);
  211.    }
  212.  
  213.    protected void installIcons(JFileChooser var1) {
  214.       this.directoryIcon = UIManager.getIcon("FileView.directoryIcon");
  215.       this.fileIcon = UIManager.getIcon("FileView.fileIcon");
  216.       this.computerIcon = UIManager.getIcon("FileView.computerIcon");
  217.       this.hardDriveIcon = UIManager.getIcon("FileView.hardDriveIcon");
  218.       this.floppyDriveIcon = UIManager.getIcon("FileView.floppyDriveIcon");
  219.       this.newFolderIcon = UIManager.getIcon("FileChooser.newFolderIcon");
  220.       this.upFolderIcon = UIManager.getIcon("FileChooser.upFolderIcon");
  221.       this.homeFolderIcon = UIManager.getIcon("FileChooser.homeFolderIcon");
  222.       this.detailsViewIcon = UIManager.getIcon("FileChooser.detailsViewIcon");
  223.       this.listViewIcon = UIManager.getIcon("FileChooser.listViewIcon");
  224.    }
  225.  
  226.    protected void installListeners(JFileChooser var1) {
  227.       this.propertyChangeListener = this.createPropertyChangeListener(var1);
  228.       if (this.propertyChangeListener != null) {
  229.          ((JComponent)var1).addPropertyChangeListener(this.propertyChangeListener);
  230.       }
  231.  
  232.       ((JComponent)var1).addPropertyChangeListener(this.model);
  233.       this.ancestorListener = new 1(this);
  234.       ((JComponent)var1).addAncestorListener(this.ancestorListener);
  235.       2 var2 = new 2(this);
  236.       ((JComponent)var1).registerKeyboardAction(var2, KeyStroke.getKeyStroke(27, 0), 1);
  237.    }
  238.  
  239.    protected void installStrings(JFileChooser var1) {
  240.       this.newFolderErrorText = UIManager.getString("FileChooser.newFolderErrorText");
  241.       this.newFolderErrorSeparator = UIManager.getString("FileChooser.newFolderErrorSeparator");
  242.       this.fileDescriptionText = UIManager.getString("FileChooser.fileDescriptionText");
  243.       this.directoryDescriptionText = UIManager.getString("FileChooser.directoryDescriptionText");
  244.       this.saveButtonText = UIManager.getString("FileChooser.saveButtonText");
  245.       this.openButtonText = UIManager.getString("FileChooser.openButtonText");
  246.       this.cancelButtonText = UIManager.getString("FileChooser.cancelButtonText");
  247.       this.updateButtonText = UIManager.getString("FileChooser.updateButtonText");
  248.       this.helpButtonText = UIManager.getString("FileChooser.helpButtonText");
  249.       this.saveButtonMnemonic = UIManager.getInt("FileChooser.saveButtonMnemonic");
  250.       this.openButtonMnemonic = UIManager.getInt("FileChooser.openButtonMnemonic");
  251.       this.cancelButtonMnemonic = UIManager.getInt("FileChooser.cancelButtonMnemonic");
  252.       this.updateButtonMnemonic = UIManager.getInt("FileChooser.updateButtonMnemonic");
  253.       this.helpButtonMnemonic = UIManager.getInt("FileChooser.helpButtonMnemonic");
  254.       this.saveButtonToolTipText = UIManager.getString("FileChooser.saveButtonToolTipText");
  255.       this.openButtonToolTipText = UIManager.getString("FileChooser.openButtonToolTipText");
  256.       this.cancelButtonToolTipText = UIManager.getString("FileChooser.cancelButtonToolTipText");
  257.       this.updateButtonToolTipText = UIManager.getString("FileChooser.updateButtonToolTipText");
  258.       this.helpButtonToolTipText = UIManager.getString("FileChooser.helpButtonToolTipText");
  259.    }
  260.  
  261.    public void installUI(JComponent var1) {
  262.       this.accessoryPanel = new JPanel(new BorderLayout());
  263.       this.filechooser = (JFileChooser)var1;
  264.       this.createModel();
  265.       this.installDefaults(this.filechooser);
  266.       this.installComponents(this.filechooser);
  267.       this.installListeners(this.filechooser);
  268.    }
  269.  
  270.    public void rescanCurrentDirectory(JFileChooser var1) {
  271.    }
  272.  
  273.    public void setDirectoryName(String var1) {
  274.    }
  275.  
  276.    public void setFileName(String var1) {
  277.    }
  278.  
  279.    public void uninstallComponents(JFileChooser var1) {
  280.    }
  281.  
  282.    protected void uninstallDefaults(JFileChooser var1) {
  283.       this.uninstallIcons(var1);
  284.       this.uninstallStrings(var1);
  285.    }
  286.  
  287.    protected void uninstallIcons(JFileChooser var1) {
  288.       this.directoryIcon = null;
  289.       this.fileIcon = null;
  290.       this.computerIcon = null;
  291.       this.hardDriveIcon = null;
  292.       this.floppyDriveIcon = null;
  293.       this.newFolderIcon = null;
  294.       this.upFolderIcon = null;
  295.       this.homeFolderIcon = null;
  296.       this.detailsViewIcon = null;
  297.       this.listViewIcon = null;
  298.    }
  299.  
  300.    protected void uninstallListeners(JFileChooser var1) {
  301.       if (this.propertyChangeListener != null) {
  302.          ((JComponent)var1).removePropertyChangeListener(this.propertyChangeListener);
  303.       }
  304.  
  305.       ((JComponent)var1).removePropertyChangeListener(this.model);
  306.       ((JComponent)var1).unregisterKeyboardAction(KeyStroke.getKeyStroke(27, 0));
  307.       ((JComponent)var1).removeAncestorListener(this.ancestorListener);
  308.       this.ancestorListener = null;
  309.    }
  310.  
  311.    protected void uninstallStrings(JFileChooser var1) {
  312.       this.saveButtonText = null;
  313.       this.openButtonText = null;
  314.       this.cancelButtonText = null;
  315.       this.updateButtonText = null;
  316.       this.helpButtonText = null;
  317.       this.saveButtonToolTipText = null;
  318.       this.openButtonToolTipText = null;
  319.       this.cancelButtonToolTipText = null;
  320.       this.updateButtonToolTipText = null;
  321.       this.helpButtonToolTipText = null;
  322.    }
  323.  
  324.    public void uninstallUI(JComponent var1) {
  325.       this.uninstallListeners(this.filechooser);
  326.       this.uninstallComponents(this.filechooser);
  327.       this.uninstallDefaults(this.filechooser);
  328.       if (this.accessoryPanel != null) {
  329.          this.accessoryPanel.removeAll();
  330.       }
  331.  
  332.       this.accessoryPanel = null;
  333.       this.getFileChooser().removeAll();
  334.    }
  335. }
  336.